package com.boco.action;

import java.util.ArrayList;
import java.util.List;

import com.boco.dao.GetEMR_MJZGHJLData;
import com.boco.dao.SentData;
import com.boco.entity.EMR_MJZGHJL;

public class InsertEMR_MJZGHJLDataAction {
	public  String insertData(){
		String url = "http://fasong.cdxp.csb/json/dzbl4";
		String resule = null;
		List<EMR_MJZGHJL> list = new ArrayList<EMR_MJZGHJL>();
		list = GetEMR_MJZGHJLData.getData();
		String userName = "dzbl4";
		String password = "322dfbf9048445cabb06cbf24e64cdcf";
		EMR_MJZGHJL temp = null;
		for(int i=0;i<list.size();i++){
			String param = null;
			temp = list.get(i);
			System.out.println(temp.getXM());
			//按照身份证删除已经存在的值。
			param = "{\"SQL\":\"delete  EMR_MJZGHJL where HZJKKH='"+
					temp.getHZJKKH()
					+"' and xm = '"+temp.getXM()+"'"
					+ "\", \"ANNOTION\":\"cdxplogs\"}";
			resule = SentData.sendPost(url, param, userName, password);
			System.out.println("删除结果："+resule);
			param = "{\"SQL\":\"INSERT INTO EMR_MJZGHJL ("
					+ "HZZSYH,"
					+ "HZJKKH,"
					+ "YBKH,"
					+ "MJZH,"
					+ "GHRQSJTHRQSJ,"
					+ "GTHBZ,"
					+ "GHLB,"
					+ "SFJZBS,"
					+ "XM,"
					+ "SZNL,"
					+ "XBDM,"
					+ "JZJGDM,"
					+ "JZJGMC,"
					+ "JZKSDM,"
					+ "JZKSMC,"
					+ "JZYSGH,"
					+ "JZYSMC,"
					+ "YLFYZFFS,"
					+ "YLFYZFFSDM,"
					+ "JZBZ,"
					+ "BCRQ,"
					+ "ZRLSH,"
					+ "ORGCODE,"
					+ "AREACODE,"
					+ "UPLOADTIME,"
					+ "SOURCEID"
					+ ") VALUES("
					+ "'" + checkStr(temp.getHZZSYH()) + "'," 
					+ "'" + checkStr(temp.getHZJKKH()) + "'," 
					+ "'" + checkStr(temp.getYBKH()) + "'," 
					+ "'" + checkStr(temp.getMJZH()) + "'," 
					+ "to_date('" + checkStr(temp.getGHRQSJTHRQSJ()) + "','yyyy-MM-dd HH24:mi:ss')," 
					+ "'" + checkStr(temp.getGTHBZ()) + "'," 
					//挂號類別長度限制1 我們是100 所有默認為1
					+ "'" + "1" + "'," 
					+ "'" + checkStr(temp.getSFJZBS()) + "'," 
					+ "'" + checkStr(temp.getXM()) + "'," 
					+ "'" + checkStr(temp.getSZNL()) + "'," 
					+ "'" + checkStr(temp.getXBDM()) + "'," 
					+ "'" + checkStr(temp.getJZJGDM()) + "'," 
					+ "'" + checkStr(temp.getJZJGMC()) + "'," 
					+ "'" + checkStr(temp.getJZKSDM()) + "'," 
					+ "'" + checkStr(temp.getJZKSMC()) + "'," 
					+ "'" + checkStr(temp.getJZYSGH()) + "'," 
					+ "'" + checkStr(temp.getJZYSMC()) + "'," 
					+ "'" + checkStr(temp.getYLFYZFFS()) + "'," 
					+ "'" + checkStr(temp.getYLFYZFFSDM()) + "'," 
					+ "'" + checkStr(temp.getJZBZ()) + "'," 
					+ "to_date('" + checkStr(temp.getBCRQ()) + "','yyyy-MM-dd HH24:mi:ss')," 
					+ "'" + checkStr(temp.getZRLSH()) + "'," 
					+ "'" + checkStr(temp.getORGCODE()) + "'," 
					+ "'" + checkStr(temp.getAREACODE()) + "'," 
					+ "sysdate," 
					+ "'dzbl4'" 
					+ ")\", \"ANNOTION\":\"cdxplogs\"}";
					resule = SentData.sendPost(url, param, userName, password);
					System.out.println(resule);
					
		}
		return resule;
		
	
		
	}
	
	public static String checkStr(Object obj){
		if (obj== null){
			obj = "";
		}
		return (String) obj;
	}
	
	
}
